
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author USER
 */
public class ConfigCPNgui extends javax.swing.JFrame {

    /**
     
     */
    public ConfigCPNgui() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        lblServer = new javax.swing.JLabel();
        lblUsername = new javax.swing.JLabel();
        lblPassword = new javax.swing.JLabel();
        lblNode = new javax.swing.JLabel();
        txtUsername = new javax.swing.JTextField();
        txtPassword = new javax.swing.JTextField();
        txtNode = new javax.swing.JTextField();
        LocalNodeType = new javax.swing.JComboBox();
        lblLocalNodeType = new javax.swing.JLabel();
        lblFSBlogo = new javax.swing.JLabel();
        txtServer = new javax.swing.JTextField();
        lblTrunkTitle = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        txtTrunk2ID = new javax.swing.JTextField();
        txtTrunk3ID = new javax.swing.JTextField();
        txtTrunk4ID = new javax.swing.JTextField();
        txtTrunk5ID = new javax.swing.JTextField();
        txtTrunk6ID = new javax.swing.JTextField();
        txtTrunk7ID = new javax.swing.JTextField();
        txtTrunk8ID = new javax.swing.JTextField();
        txtTrunk1ID = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        Trunk1Type = new javax.swing.JComboBox();
        Trunk2Type = new javax.swing.JComboBox();
        Trunk3Type = new javax.swing.JComboBox();
        Trunk4Type = new javax.swing.JComboBox();
        Trunk5Type = new javax.swing.JComboBox();
        Trunk6Type = new javax.swing.JComboBox();
        Trunk7Type = new javax.swing.JComboBox();
        Trunk8Type = new javax.swing.JComboBox();
        txtTrunk1IP = new javax.swing.JTextField();
        txtTrunk2IP = new javax.swing.JTextField();
        txtTrunk3IP = new javax.swing.JTextField();
        txtTrunk4IP = new javax.swing.JTextField();
        txtTrunk5IP = new javax.swing.JTextField();
        txtTrunk6IP = new javax.swing.JTextField();
        txtTrunk7IP = new javax.swing.JTextField();
        txtTrunk8IP = new javax.swing.JTextField();
        btnSubmit = new javax.swing.JButton();
        btnClear = new javax.swing.JButton();
        btnExit = new javax.swing.JButton();
        lblLocalNodeTitle = new javax.swing.JLabel();
        lblClassification = new javax.swing.JLabel();
        LocalClassification = new javax.swing.JComboBox();

        jMenuItem1.setText("jMenuItem1");
        jPopupMenu1.add(jMenuItem1);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        lblServer.setText("CCM IP Address:");

        lblUsername.setText("Username:");

        lblPassword.setText("Password:");

        lblNode.setText("5 Digit Node ID:");

        LocalNodeType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select:", "JNN", "CPN", "SSS", "UHN" }));

        lblLocalNodeType.setText("Type:");

        lblFSBlogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Logo.png"))); // NOI18N

        lblTrunkTitle.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblTrunkTitle.setText("Trunk Configuration");

        jLabel7.setText("Node ID:");

        jLabel10.setText("#1");

        jLabel11.setText("#2");

        jLabel12.setText("#3");

        jLabel13.setText("#4");

        jLabel14.setText("#5");

        jLabel15.setText("#6");

        jLabel16.setText("#7");

        jLabel17.setText("#8");

        jLabel19.setText("Type:");

        jLabel20.setText("CCM IP:");

        Trunk1Type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select:", "JNN", "CPN", "SSS", "UHN" }));

        Trunk2Type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select:", "JNN", "CPN", "SSS", "UHN" }));

        Trunk3Type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select:", "JNN", "CPN", "SSS", "UHN" }));

        Trunk4Type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select:", "JNN", "CPN", "SSS", "UHN" }));

        Trunk5Type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select:", "JNN", "CPN", "SSS", "UHN" }));

        Trunk6Type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select:", "JNN", "CPN", "SSS", "UHN" }));

        Trunk7Type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select:", "JNN", "CPN", "SSS", "UHN" }));

        Trunk8Type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select:", "JNN", "CPN", "SSS", "UHN" }));

        btnSubmit.setText("Submit");
        btnSubmit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSubmitActionPerformed(evt);
            }
        });

        btnClear.setText("Clear");
        btnClear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnClearActionPerformed(evt);
            }
        });

        btnExit.setText("Exit");
        btnExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExitActionPerformed(evt);
            }
        });

        lblLocalNodeTitle.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblLocalNodeTitle.setText("Local Node");

        lblClassification.setText("Classification:");

        LocalClassification.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select:", "N", "S" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(231, 231, 231)
                .addComponent(btnSubmit)
                .addGap(32, 32, 32)
                .addComponent(btnClear)
                .addGap(36, 36, 36)
                .addComponent(btnExit)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(lblNode)
                                        .addComponent(lblLocalNodeType, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(lblClassification))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(LocalNodeType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(txtNode, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(LocalClassification, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(lblServer)
                                        .addComponent(lblUsername)
                                        .addComponent(lblPassword))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(txtUsername)
                                        .addComponent(txtPassword)
                                        .addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addComponent(lblFSBlogo)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(97, 97, 97)
                        .addComponent(lblLocalNodeTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(111, 111, 111)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel11)
                            .addComponent(jLabel10)
                            .addComponent(jLabel12)
                            .addComponent(jLabel13)
                            .addComponent(jLabel14)
                            .addComponent(jLabel15)
                            .addComponent(jLabel16)
                            .addComponent(jLabel17))
                        .addGap(30, 30, 30)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(txtTrunk7ID, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtTrunk6ID, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtTrunk1ID, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtTrunk5ID, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtTrunk2ID, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtTrunk3ID, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtTrunk4ID, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtTrunk8ID, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(1, 1, 1))
                            .addComponent(jLabel7))
                        .addGap(5, 5, 5)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(Trunk1Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtTrunk1IP, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(5, 5, 5)
                                        .addComponent(jLabel19))
                                    .addComponent(Trunk2Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(32, 32, 32)
                                        .addComponent(jLabel20))
                                    .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtTrunk2IP, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(Trunk8Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtTrunk8IP))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(Trunk7Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtTrunk7IP))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(Trunk6Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtTrunk6IP))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(Trunk5Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtTrunk5IP))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(Trunk4Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtTrunk4IP))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(Trunk3Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtTrunk3IP, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(84, 84, 84)
                        .addComponent(lblTrunkTitle)))
                .addGap(49, 49, 49))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblFSBlogo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblLocalNodeTitle)
                        .addGap(13, 13, 13)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblServer, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtServer, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblUsername)
                            .addComponent(txtUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblPassword))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblNode))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(LocalNodeType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblLocalNodeType))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblClassification)
                            .addComponent(LocalClassification, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblTrunkTitle)
                        .addGap(25, 25, 25)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtTrunk1ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel10))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel11)
                                    .addComponent(txtTrunk2ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtTrunk3ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel12))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtTrunk4ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel13))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtTrunk5ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel14))
                                .addGap(8, 8, 8)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtTrunk6ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel15))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtTrunk7ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel16))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtTrunk8ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel17)))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel20)
                                    .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(Trunk1Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtTrunk1IP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(Trunk2Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtTrunk2IP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(Trunk3Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtTrunk3IP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(Trunk4Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtTrunk4IP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(Trunk5Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtTrunk5IP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(8, 8, 8)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(Trunk6Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtTrunk6IP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(Trunk7Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtTrunk7IP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(Trunk8Type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtTrunk8IP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSubmit)
                    .addComponent(btnClear)
                    .addComponent(btnExit))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
        System.exit(0);
    }//GEN-LAST:event_btnExitActionPerformed

    private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed
        txtServer.setText( "" ) ;												
        txtUsername.setText( "" ) ;
	txtPassword.setText( "" ) ;											
        txtNode.setText( "" ) ;
        txtTrunk1IP.setText( "" ) ;											
        txtTrunk2IP.setText( "" ) ;
        txtTrunk3IP.setText( "" ) ;											
        txtTrunk4IP.setText( "" ) ;
        txtTrunk5IP.setText( "" ) ;											
        txtTrunk6IP.setText( "" ) ;
        txtTrunk7IP.setText( "" ) ;											
        txtTrunk8IP.setText( "" ) ;
        txtTrunk1ID.setText( "" ) ;											
        txtTrunk2ID.setText( "" ) ;
        txtTrunk3ID.setText( "" ) ;											
        txtTrunk4ID.setText( "" ) ;
        txtTrunk5ID.setText( "" ) ;											
        txtTrunk6ID.setText( "" ) ;
        txtTrunk7ID.setText( "" ) ;											
        txtTrunk8ID.setText( "" ) ;
        LocalNodeType.setSelectedItem("Select:") ;
        Trunk1Type.setSelectedItem("Select:") ;
        Trunk2Type.setSelectedItem("Select:") ;
        Trunk3Type.setSelectedItem("Select:") ;
        Trunk4Type.setSelectedItem("Select:") ;
        Trunk5Type.setSelectedItem("Select:") ;
        Trunk6Type.setSelectedItem("Select:") ;
        Trunk7Type.setSelectedItem("Select:") ;
        Trunk8Type.setSelectedItem("Select:") ;
        LocalClassification.setSelectedItem("Select:");
    }//GEN-LAST:event_btnClearActionPerformed

    private static String validIP ( String ip ) {
			
			try { 
		        if ( ip == null || ip.isEmpty()) { 
		            return null ; 
		        } 
		        
		        String[] parts = ip.split( "\\." ) ; 
		        if ( parts.length != 4 ) { 
		            return null ; 
		        } 
		 
		        for ( String s : parts ) { 
		            int i = Integer.parseInt( s ) ; 
		            if ( (i < 0) || (i > 255 ) ) { 
		                return null ; 
		            } 
		        }
		        
		        int counter = 0 ; 
		        for( int i = 0 ; i < ip.length() ; i++ ) { 
		            if( ip.charAt(i) == '.' ) { 
		                counter++ ; 
		            }  
		        }
		        if( counter != 3 ) return null ;

		        return ip ; 
		    } catch ( NumberFormatException nfe ) { 
		        return null ; 
		    } 
		}
		
		private static String validUsername ( String username ) {
			
			try {
				if ( username == null || username.isEmpty()) {
					return null ;
				}
				return username ;
			} catch ( NumberFormatException nfe ) { 
		        return null ; 
			}
		}
		
		private static String validPassword ( String password ) {

			try {
				if ( password == null || password.isEmpty()) {
					return null ;
				}
				return password ;
			} catch ( NumberFormatException nfe ) { 
		        return null ; 
			}
		}

		private static String isInteger( String node )   
		{   
		   try  
		   {   
		      Integer.parseInt( node ) ;   
		      return node ;   
		   }   
		   catch( NumberFormatException e )   
		   {   
		      return null ;   
		   }   
		}  
		
		private static String validNode ( String node ) {

			try {
				if ( node == null || node.isEmpty()) {
					return null ;
				}
				
				if ( node.length() != 5 ) {
					return null ;
				}
				
				return node ;
			} catch ( NumberFormatException nfe ) { 
		        return null ; 
			}
		}
    
    private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSubmitActionPerformed
      
        String[] TrunkIPs = {txtTrunk1IP.getText() , txtTrunk2IP.getText() , txtTrunk3IP.getText() , txtTrunk4IP.getText() , txtTrunk5IP.getText() , txtTrunk6IP.getText() , txtTrunk7IP.getText() , txtTrunk8IP.getText() };
        String[] TrunkIDs = {txtTrunk1ID.getText() , txtTrunk2ID.getText() , txtTrunk3ID.getText() , txtTrunk4ID.getText() , txtTrunk5ID.getText() , txtTrunk6ID.getText() , txtTrunk7ID.getText() , txtTrunk8ID.getText() };
        String[] TrunkTypes = {(String)Trunk1Type.getSelectedItem() , (String)Trunk2Type.getSelectedItem() , (String)Trunk3Type.getSelectedItem() , (String)Trunk4Type.getSelectedItem() , (String)Trunk5Type.getSelectedItem() , (String)Trunk6Type.getSelectedItem() , (String)Trunk7Type.getSelectedItem() , (String)Trunk8Type.getSelectedItem() };
        int i ;
        
        ConfigCPNmain cpn1 = new ConfigCPNmain();
        for( i = 0 ; i < 8 ; i++){
            if((("".equals(TrunkIDs[i]) ) && ("Select:".equals((String)TrunkTypes[i])) && ("".equals(TrunkIPs[i]))) || ((!"".equals(TrunkIDs[i]) ) && (!"Select:".equals((String)TrunkTypes[i])) && (!"".equals(TrunkIPs[i])))) {
                 if (i==7){ 
                     if((validIP( txtServer.getText()) != null) && ( validUsername( txtUsername.getText()) != null ) && ( validPassword( txtPassword.getText()) != null) && ( validNode( txtNode.getText()) != null ) && ( isInteger( txtNode.getText()) != null ) && (!"Select:".equals((String)LocalNodeType.getSelectedItem()) )) {
         
                        try {
                        cpn1.main2( txtServer.getText() , txtUsername.getText() , txtPassword.getText() , txtNode.getText() , (String)LocalNodeType.getSelectedItem() , (String)LocalClassification.getSelectedItem() , TrunkIPs , TrunkIDs , TrunkTypes );
                            } catch (InterruptedException ex) {
                        Logger.getLogger(ConfigCPNgui.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                     else{
                        JOptionPane.showMessageDialog( this, "Invalid or Missing Data. Please Check the Following Required Fields: \n\n " +
					"1. CCM IP Address \n 2. Username \n 3. Password \n 4. 5 Digit Node ID \n 5. Classification (N/S)", "Invalid or Missing Data", JOptionPane.ERROR_MESSAGE ) ;
                        break;
                        }
                    }
                 else{
                   continue;
                     }
            }
            else{
                    JOptionPane.showMessageDialog( this, "Invalid Trunk Data - Ensure complete entry of data.", "Invalid Trunk Data", JOptionPane.ERROR_MESSAGE ) ;
                   break;
            }
            }
        
			
                         
    }//GEN-LAST:event_btnSubmitActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        
        
        
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ConfigCPNgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ConfigCPNgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ConfigCPNgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ConfigCPNgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {
            
            @Override
            public void run() {
                new ConfigCPNgui().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox LocalClassification;
    public javax.swing.JComboBox LocalNodeType;
    public javax.swing.JComboBox Trunk1Type;
    public javax.swing.JComboBox Trunk2Type;
    public javax.swing.JComboBox Trunk3Type;
    public javax.swing.JComboBox Trunk4Type;
    public javax.swing.JComboBox Trunk5Type;
    public javax.swing.JComboBox Trunk6Type;
    public javax.swing.JComboBox Trunk7Type;
    public javax.swing.JComboBox Trunk8Type;
    private javax.swing.JButton btnClear;
    private javax.swing.JButton btnExit;
    private javax.swing.JButton btnSubmit;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JLabel lblClassification;
    private javax.swing.JLabel lblFSBlogo;
    private javax.swing.JLabel lblLocalNodeTitle;
    private javax.swing.JLabel lblLocalNodeType;
    private javax.swing.JLabel lblNode;
    private javax.swing.JLabel lblPassword;
    private javax.swing.JLabel lblServer;
    private javax.swing.JLabel lblTrunkTitle;
    private javax.swing.JLabel lblUsername;
    public javax.swing.JTextField txtNode;
    public javax.swing.JTextField txtPassword;
    public javax.swing.JTextField txtServer;
    public javax.swing.JTextField txtTrunk1ID;
    public javax.swing.JTextField txtTrunk1IP;
    public javax.swing.JTextField txtTrunk2ID;
    public javax.swing.JTextField txtTrunk2IP;
    public javax.swing.JTextField txtTrunk3ID;
    public javax.swing.JTextField txtTrunk3IP;
    public javax.swing.JTextField txtTrunk4ID;
    public javax.swing.JTextField txtTrunk4IP;
    public javax.swing.JTextField txtTrunk5ID;
    public javax.swing.JTextField txtTrunk5IP;
    public javax.swing.JTextField txtTrunk6ID;
    public javax.swing.JTextField txtTrunk6IP;
    public javax.swing.JTextField txtTrunk7ID;
    public javax.swing.JTextField txtTrunk7IP;
    public javax.swing.JTextField txtTrunk8ID;
    public javax.swing.JTextField txtTrunk8IP;
    public javax.swing.JTextField txtUsername;
    // End of variables declaration//GEN-END:variables
}
